#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5;
struct node{
	int d,v,a,e;
}car[N + 5];
int t,n,m,L,V,p[N + 5],o1[N + 5],ans;
bool o[N + 5][2];
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin >> t;
	while(t--){
		cin >> n >> m >> L >> V;
		for(int i = 1;i <= n;i++){
			cin >> car[i].d >> car[i].v >> car[i].a;
			if(car[i].a < 0){
				car[i].e = (car[i].d + car[i].a - 1) / car[i].a;
			}
			else{
				car[i].e = L;
			}
		}
		for(int i = 1;i <= m;i++){
			cin >> p[i];
			for(int j = 1;j <= n;j++){
				if((car[j].d > p[i]) && (car[j].e < p[i])){
					continue;
				}
				int s = p[i] - car[j].d;
				int v1 = car[j].v * car[j].v + 2 * car[j].a * s;
				if(v1 > V * V){
					o[j][i % 2] = true;
					o1[i % 2]++;
				}
				if(o[j][(i + 1) % 2]){
					o[j][i % 2] = true;
					o1[i]++;
				}
			}		
		}
		cout << o1[m] << " ";
		ans = n;
		for(int i = m;i >= 1;i--){
			if(o1[i] == n){
				ans = i;
			}
		}
		cout << (n - ans) << endl;
	}
	fclose(stdin);
    fclose(stdout);
	return 0;
}
